package com.globallogic.strelchuk.usermanager.service;

import java.util.List;

import javax.inject.Named;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.globallogic.strelchuk.usermanager.dao.UserDao;
import com.globallogic.strelchuk.usermanager.domain.User;

@Named
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserDao userDao;

	@Transactional
	public void addAUser(User user) {
		userDao.addUser(user);		
	}

	@Transactional
	public List<User> listAllUsers() {
		return userDao.listAllUsers();
	}

	@Transactional
	public void removeUser(Integer id) {
		userDao.removeUser(id);		
	}

	@Transactional
	public void editUser(User user, Integer id) {
		userDao.editUser(user, id);		
	}

	@Transactional
	public User getUserById(int id) {
		return userDao.getUserById(id);
	}
	
	@Transactional
	public boolean isCorrectPassword(User user) {
		return userDao.isCorrectPassword(user);
	}
	
	@Transactional
	public boolean isUserSignedIn(User user) {
		return userDao.isUserSignedIn(user);
	}
	
	@Transactional
	public User getUserByLogin(String login) {
		return userDao.getUserByLogin(login);
	}
}
